﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Customer.aspx.cs" Inherits="WebApplication2.Customer" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="script/jquery-1.9.1.min.js"></script>
   <script type="text/javascript">
       $(document).ready(function () {
           $('#Customers').change(function () {
               $.ajax({
                   type: "POST",
                   contentType: "application/json; charset=utf-8",
                   data: "{ CustomerID: '" + $('#Customers').val() + "'}",
                   url: "Customer.aspx/FetchCustomer",
                   dataType: "json",
                   success: function (data) {
                       var Company = data.d;
                       $('#CustomerDetails').append
              ('<p><strong>' + Company.CompanyName + "</strong><br />" +
              Company.Address + "<br />" +
              Company.City + "<br />" +
              Company.Region + "<br />" +
              Company.PostalCode + "<br />" +
              Company.Country + "<br />" +
              Company.Phone + "<br />" +
              Company.Fax + "</p>")
                   }
               });
           });
       });
</script>
</head>
<body>
    <form id="form1" runat="server">
        <div id="SelectCustomers">
            <asp:DropDownList ID="Customers" runat="server">
            </asp:DropDownList>
        </div>
        <div id="CustomerDetails"></div>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>
</body>
</html>
